package com.liyan358292798.template.mvc.controller.navigation;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.uml2.uml.UseCase;

import com.liyan358292798.template.mvc.controller.ActionService;

public class NavigationGenerate {
	
	private static ActionService ActionService = new ActionService();

	public List<List<UseCase>> getNavigationAccessPaths(List<List<UseCase>> list){
		List<List<UseCase>> newList = new ArrayList<>();
		for(List<UseCase> item : list){
			List<UseCase> newSubList = new ArrayList<>();
			for(UseCase subItem : item){
				if(ActionService.isAccess(subItem)){
					newSubList.add(subItem);
				}
			}
			//
			if(!newSubList.isEmpty()){
				newList.add(newSubList);
			}
		}
		return newList;
	}
	
	public List<List<UseCase>> removeItemFirst(List<List<UseCase>> list){
		List<List<UseCase>> newList = new ArrayList<>();
		for(List<UseCase> item : list){
			List<UseCase> newSubList = new ArrayList<>();
			boolean isStart = true;
			for(UseCase subItem : item){
				if(!isStart){
					newSubList.add(subItem);
				}
				isStart = false;
			}
			//
			if(!newSubList.isEmpty()){
				newList.add(newSubList);
			}
		}
		return newList;
	}
	
//	public List<UseCase> getPreNavigation(UseCase useCase){
//		List<UseCase> list = new ArrayList<>();
//		//
//		List<List<UseCase>> paths = UseCaseService.getIncludeTargetPaths(useCase);
//		if(paths.isEmpty()){
//			return list;
//		}else{
//			for(List<UseCase> path : paths){
//				if(path.size()>1){
//					list.add(path.get(1));
//				}
//			}
//		}
//		return list;
//	}
	
//	public List<Include> getPreNavigationIncludes(UseCase useCase){
//		List<Include> list = new ArrayList<>();
//		//
//		List<List<UseCase>> paths = UseCaseService.getIncludeTargetPaths(useCase);
//		if(paths.isEmpty()){
//			return list;
//		}else{
//			for(List<UseCase> path : paths){
//				List<Include> includes = UseCaseService.getIncludePath(path);
//				if(includes.size()>1){
//					list.add(includes.get(1));
//				}
//			}
//		}
//		return list;
//	}
	
}
